#include "label.h"

Label::Label(Game* game) : GameObject(game) {
    this->font = 0;
    this->fontName = "font";
    this->fontTexture = 0;
    this->textAlignment = TEXTALIGNMENT_LEFT;
}

Label::~Label(void) {
}

string Label::GetFontName() const {
    return this->fontName;
}

void Label::SetFontName(string val) {
    this->fontName = val;
}

Point Label::GetPosition() const {
    return this->position;
}

void Label::SetPosition(Point val) {
    this->position = val;
}

TextAlignment Label::GetTextAlignment() const {
    return this->textAlignment;
}

void Label::SetTextAlignment(TextAlignment val) {
    this->textAlignment = val;
}

string Label::GetText() const {
    return this->text;
}

void Label::SetText(string val) {
    this->text = val;
}

void Label::Draw(float timeDelta) {
    this->GetGame()->GetContentManager()->UseTexture(this->fontTexture);
    switch (this->textAlignment) {
    case TEXTALIGNMENT_LEFT:
        this->font->printfL(this->position.x, this->position.y, 127, 127, 127, 127, this->text.c_str());
        break;
    case TEXTALIGNMENT_RIGHT:
        this->font->printfR(this->position.x, this->position.y, 127, 127, 127, 127, this->text.c_str());
        break;
    case TEXTALIGNMENT_CENTER:
        this->font->printfC(this->position.x, this->position.y, 127, 127, 127, 127, this->text.c_str());
        break;
    }
}

void Label::LoadContent() {
    this->font = this->GetGame()->GetContentManager()->LoadFont((this->fontName + ".dat").c_str());
    this->fontTexture = this->GetGame()->GetContentManager()->LoadTexture((this->fontName + ".bmp").c_str());
}

void Label::UnloadContent() {
}